package com.leyou.user.web;

import com.leyou.user.dto.AddressDTO;
import com.leyou.user.dto.UserDTO;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/address")
public class AddressController {

    /**
     * 根据地址id以及用id查询对应的地址信息
     * @param id
     * @param userId
     * @return
     */
    @GetMapping
    public ResponseEntity<AddressDTO> queryAddressByIdAndUserId(
            @RequestParam("id")Long id,
            @RequestParam("userId")Long userId){

        AddressDTO addressDTO = new AddressDTO();
        addressDTO.setAddressee("刘士奇");
        addressDTO.setProvince("上海市");
        addressDTO.setCity("上海市");
        addressDTO.setDistrict("浦东新区");
        addressDTO.setStreet("航堵路18号");
        addressDTO.setId(id);
        addressDTO.setIsDefault(true);
        addressDTO.setPhone("13838383838");
        addressDTO.setPostcode("110119");
        addressDTO.setUserId(userId);
        return ResponseEntity.ok(addressDTO);
    }
}
